package Xuanke.entities;

import java.util.ArrayList;
import java.util.List;

public class Student extends Person {
    private List<Course> selectedCourses = new ArrayList<>();

    public Student(String id, String name, String gender) {
        super(id, name, gender);
    }
    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println("学生 " + getName() + " 选修课程：" + course.getCourseName());
    }

    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println("学生 " + getName() + " 退选课程：" + course.getCourseName());
        } else {
            System.out.println("学生 " + getName() + " 未选修该课程，退课失败");
        }
    }
    public void printCourseSchedule() {
        System.out.println("=== 学生 " + getName() + " 的课表 ===");
        System.out.println("编号\t        课程名称\t上课教室\t学分\t课程类型\t授课教师");
        for (Course course : selectedCourses) {
            String teacherName = course.getTeacherName();
            System.out.println(course.getCourseId() + "\t" + course.getCourseName() + "\t" + course.getClassroom() + "\t" + course.getTime()+"\t" + course.getCredit() + "\t" + teacherName);
        }
    }

    public void printInfo() {
        super.printInfo();
        System.out.println("已选课程数量：" + selectedCourses.size());
    }

    public List<Course> getSelectedCourses() {
        return selectedCourses;
    }
}